package com.test.demo.controller;

import com.test.demo.service.IDemoService;
import com.test.mvcframework.annotations.Autowired;
import com.test.mvcframework.annotations.Controller;
import com.test.mvcframework.annotations.RequestMapping;
import com.test.demo.annotation.Security;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping("/demo")
public class DemoController {
    @Autowired
    private IDemoService demoService;

    @Security({"test"})
    @RequestMapping("/test")
    public String test(HttpServletRequest request, HttpServletResponse response, String name) {
        request.setAttribute("result", "Only user 'test' is able to access this page!");
        return "index";
    }

    @Security({"temp"})
    @RequestMapping("/temp")
    public String temp(HttpServletRequest request, HttpServletResponse response, String name) {
        request.setAttribute("result", "Only user 'temp' is able to access this page!");
        return "index";
    }

    @Security({"*"})
    @RequestMapping("/all")
    public String all(HttpServletRequest request, HttpServletResponse response, String name) {
        request.setAttribute("result", "Any user are able to access this page!");
        return "index";
    }
}
